Quaqua 4.4.7 2008-07-16

ch.randelshofer.quaqua.filechooser
Class Files

java.lang.Object
  extended by ch.randelshofer.quaqua.filechooser.Files

public class Files
extends java.lang.Object

This class contains various methods for manipulating Files. The current implementation only works on Mac OS X.

Version:
4.1 2008-05-01 Added support for 64 bit JNILib.
4.0 2008-03-26 Added version check to native library.
3.1 2007-11-24 On UnsatisfiedLinkError retry with absolute path to load libquaqua.jnilib.
3.0 2007-10-30 On Mac OS X Leopard method getIconImage(File, size) may return icons which are too big.
2.0 2007-04-18 Added methods getKind(), getIconImage(), getIcon(), based on code contributed by Rolf Howarth.
1.6 2006-09-17 Deprecated "Quaqua.JNI.isPreloaded". The new system property name is "Quaqua.jniIsPreloaded".
1.5 2006-03-12 Quaqua.JNI.isPreloaded can be set to true to prevent Quaqua from loading the JNI library on its own.
1.4.1 2006-02-13 Print a warning on System.err, if JNI library is not available.
1.4 205-08-26 Method getAbsoluteFile supports now Windows paths.
1.3 2005-06-30 Methods canWorkWithAliases and canWorkWithLabels added.
1.2.1 2005-06-5 Moved calls to System.getProperty into QuaquaManager.
1.1 2005-01-22 Method getLabel added.
1.0.1 2004-11-01 Renamed JNI Library from "QuaquaFiles" to "quaqua".
1.0 October 8, 2004 Created.
Author:
Werner Randelshofer

Field Summary
static int FILE_TYPE_ALIAS
           
static int FILE_TYPE_DIRECTORY
           
static int FILE_TYPE_FILE
           
static int FILE_TYPE_UNKOWN
           
 
Method Summary
static boolean canWorkWithAliases()
          Returns true if this class can work with aliases.
static boolean canWorkWithLabels()
          Returns true if this class can work with labels.
static java.io.File getAbsoluteFile(java.io.File f)
          Converts the path name denoted by the file to an absolute path.
static int getFileType(java.io.File f)
          Returns the file type: 0=file, 1=directory, 2=alias, -1=unknown.
static javax.swing.Icon getIcon(java.io.File file, int size)
          Returns the icon for the specified file.
static java.awt.image.BufferedImage getIconImage(java.io.File file, int size)
          Returns the icon image for the specified file.
static java.lang.String getKindString(java.io.File file)
          Returns the kind string of the specified file.
static int getLabel(java.io.File f)
          Returns the label of the specified file.
static java.awt.Color getLabelColor(int label, int type)
          Returns the color of the specified label.
static java.io.File resolveAlias(byte[] serializedAlias, boolean noUI)
          Resolves a serialized Alias to a File object.
static java.io.File resolveAlias(java.io.File alias, boolean noUI)
          Resolves an alias to a File object.
static int resolveAliasType(byte[] serializedAlias, boolean noUI)
          Resolves an alias to a type info.
static int resolveAliasType(java.io.File alias, boolean noUI)
          Resolves an alias to a type info.
static byte[] toSerializedAlias(java.io.File f)
          Creates a serialized Alias.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_TYPE_ALIAS

public static final int FILE_TYPE_ALIAS
See Also:
Constant Field Values

FILE_TYPE_DIRECTORY

public static final int FILE_TYPE_DIRECTORY
See Also:
Constant Field Values

FILE_TYPE_FILE

public static final int FILE_TYPE_FILE
See Also:
Constant Field Values

FILE_TYPE_UNKOWN

public static final int FILE_TYPE_UNKOWN
See Also:
Constant Field Values
Method Detail

getAbsoluteFile

public static java.io.File getAbsoluteFile(java.io.File f)
Converts the path name denoted by the file to an absolute path. Relative paths are always resolved against the home directory of the user and not against the current user.dir directory. The returned file objects represents an absolute path containing no '.' and '..' relative path components. This method acts solely on the textual representation of the file and therefore does does not necessarily canonicalize the path nor does it resolve aliases.

Parameters:
f - The file which we must ensure contains an absolute path.

canWorkWithAliases

public static boolean canWorkWithAliases()
Returns true if this class can work with aliases.


getFileType

public static int getFileType(java.io.File f)
Returns the file type: 0=file, 1=directory, 2=alias, -1=unknown.


resolveAlias

public static java.io.File resolveAlias(java.io.File alias,
                                        boolean noUI)
Resolves an alias to a File object.

Parameters:
alias - the Alias file to be resolved.
noUI - Set this to true, if the alias should be resolved without user interaction.
Returns:
Returns the resolved File object.

resolveAliasType

public static int resolveAliasType(java.io.File alias,
                                   boolean noUI)
Resolves an alias to a type info. Resolves the type of the path if the provided path is not an alias.

Parameters:
alias - the path to the alias to be resolved.
noUI - Set this to true, if the alias should be resolved without user interaction.
Returns:
Returns the resolved path.

toSerializedAlias

public static byte[] toSerializedAlias(java.io.File f)
Creates a serialized Alias.

Returns:
A serialized alias or null, if serialization could not be done.

resolveAlias

public static java.io.File resolveAlias(byte[] serializedAlias,
                                        boolean noUI)
Resolves a serialized Alias to a File object.

Parameters:
noUI - Set this to true, if the alias should be resolved without user interaction.
Returns:
A File or null, if the serialized Alias could not be resolved.

resolveAliasType

public static int resolveAliasType(byte[] serializedAlias,
                                   boolean noUI)
Resolves an alias to a type info. Resolves the type of the path if the provided path is not an alias.

Parameters:
serializedAlias - the path to the alias to be resolved.
noUI - Set this to true, if the alias should be resolved without user interaction.
Returns:
Returns the resolved path.

canWorkWithLabels

public static boolean canWorkWithLabels()
Returns true if this class can work with labels.


getLabel

public static int getLabel(java.io.File f)
Returns the label of the specified file. The label is a value in the interval from 0 through 7. Returns -1 if the label could not be determined, e.g. if the file does not exist.


getLabelColor

public static java.awt.Color getLabelColor(int label,
                                           int type)
Returns the color of the specified label. Returns null, if the label does not have a color.

Parameters:
label - value from 0 through 7
type - 0=dark enabled,1=bright enabld,2=dark disabled,3=bright enabled

getIconImage

public static java.awt.image.BufferedImage getIconImage(java.io.File file,
                                                        int size)
Returns the icon image for the specified file. If the file does not exist, a generic image is returned. XXX - Returns null if it was not possible to get the icon image. We should return a generic image in this case!


getIcon

public static javax.swing.Icon getIcon(java.io.File file,
                                       int size)
Returns the icon for the specified file. If the file does not exist, a generic icon is returned.


getKindString

public static java.lang.String getKindString(java.io.File file)
Returns the kind string of the specified file. The description is localized in the current Locale of the Finder.

Returns:
The kind or null, if it couldn't be determined.

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.